<?php

namespace App\Exception\Handler;

use App\Exception\LogicException;
use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\Validation\ValidationException;
use Psr\Http\Message\ResponseInterface;
use Throwable;

/**
 * rpc中的逻辑异常不需要记录，因为会传递到调用方
 */
class RpcExceptionHandler extends ExceptionHandler
{

    public function handle(\Throwable $throwable, ResponseInterface $response)
    {
        $this->stopPropagation();

        return $response;
    }

    public function isValid(Throwable $throwable): bool
    {
        return $throwable instanceof LogicException;
    }
}